import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
const isDir = (type) => type === 0;
export const columns: BasicColumn[] = [
  {
    title: '消息名称',
    dataIndex: 'name',
    width: 150,
    align: 'center',
    sorter: true,
  },
  {
    title: '消息类型',
    dataIndex: 'typeId',
    width: 150,
    align: 'center',
    sorter: true,
    customRender: ({ text }) => {
      if(text === "General" || "1"){
        return "普通消息"
      }else{
        return "重要消息"
      }
		},
  },
  {
    title: '发送地址',
    dataIndex: 'publishAddress',
    width: 150,
    align: 'center',
    sorter: true,
  },
  {
    title: '发布状态',
    dataIndex: 'status',
    width: 150,
    align: 'center',
    sorter: true,
    customRender: ({ text }) => {
			if (text === 'InReview' || text =="1") {
				return '审核中';
			} else if (text === 'Reject' || text == "2") {
				return '驳回';
			} else if(text ==="Published" || text == "3"){
				return '已发布';
			}else{
        return '已撤回'
      }
		},
  },
  {
    title: '发布方式',
    width: 150,
    align: 'publishMode',
    sorter: true,
    customRender: ({ record }) => {
      return record.status == '1' ? '定时发布' : '立即发布';
    },
  },
  {
    title: '发布者',
    dataIndex: 'publisher',
    width: 150,
    align: 'center',
    sorter: true,
  },
  {
    title: '创建时间',
    dataIndex: 'createdTime',
    width: 150,
    align: 'center',
    sorter: true,
  },
  {
    title: '发布时间',
    dataIndex: 'publishTime',
    width: 150,
    align: 'center',
    sorter: true,
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'id',
    label: '',
    component: 'Input',
    show: false,
  },
  {
    field: 'name',
    label: '信息名称',
    required: true,
    component: 'Input',
  },
  // {
  //   label: '信息名称',
  //   field: 'name',
  //   component: 'rwSelect',
  //   required: true,
  //   componentProps: {
  //     type: 'org',
  //     label: 'name',
  //     key: 'id',
  //   },
  // },
  {
    field: 'typeId',
    label: '消息类型',
    required: true,
    component: 'Select',
    componentProps: {
      options: [
        { value: 'General', label: '普通消息' },
        { value: 'Important', label: '重要消息' },
      ],
    },
  },
  {
    field: 'publishAddress',
    label: '发布地址',
    required: true,
    component: 'Input',
  },
  {
    field: 'publishMode',
    label: '发布方式',
    required: true,
    component: 'Select',
    componentProps: {
      options: [
        { value: 'Scheduled ', label: '定时发布' },
        { value: 'Immediately', label: '立即发布' },
      ],
    },
  },
  {
    field: 'publisher',
    label: '发布者',
    required: true,
    component: 'Input',
  },
  {
    field: 'remark',
    label: '描述',
    required: false,
    component: 'Input',
    ifShow: ({ values }) => (values.id),
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    label: '消息类型',
    field: 'TypeId',
    component: 'Select',
    componentProps: {
      placeholder: '请选择消息类型',
      options: [
        { value: 'General ', label: '普通' },
        { value: 'Important', label: '重要' },
      ],
    },
  },
  {
    field: 'Publisher',
    label: '发布者',
    component: 'Input',
    colProps: { span: 8 },
    componentProps: {
      placeholder: '请输入发布者姓名/人员编号',
    },
  },
  {
    field: 'PublishTime',
    label: '时间',
    component: 'RangeDate',
    componentProps: {
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      showTime: true,
    },
    colProps: { span: 4, xxl: 4 },
  },
];
